/* LITS data */

*This is to get:
*Table2
*Table4
*Table5
*TableA11

*
/* use LTIS 2016 dataset from https://www.ebrd.com/what-we-do/economic-research-and-data/data/lits.html*/

clear all
estimates clear

global dopath "C:/Users/bogdanp/Dropbox/Legacies_Central_Europe"
*global dopath "/Users/bgpopescu/Dropbox/Legacies_Central_Europe"

use "$dopath/data/lits_data.dta", clear

*********
*TABLE 2*
*********

/* educational achievement */
label variable p_ottoman "Prop. Ottoman"
eststo clear
quietly reg q109_1 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model2, title("Respondent's Highest Education Completed")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"
estadd local Income "No"


/* even wiht post treatment income control */
quietly reg q109_1 p_ottoman  tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban PRq315 i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model3, title("Respondent's Highest Education Completed")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"
estadd local Income "Yes"


/* secondary respondent*/
*reg q109_2 p_ottoman  i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
quietly reg q109_2 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model4, title("Respondent's Highest Education Completed")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"
estadd local Income "No"


/* father educ*/
quietly reg q110_1 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model5, title("Father's Highest Education Completed")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"
estadd local Income "No"

/* mother educ*/
quietly reg q111_1 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model6, title("Mother's Highest Education Completed")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"
estadd local Income "No"


/* books growing up */
replace q203 = . if q203<=0 | q203 >6
*reg q203 p_ottoman age_pr gender_pr q109_1 urban  i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
quietly reg q203 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban  i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model7, title("No. Books Childhood")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"
estadd local Income "No"

esttab using "$dopath/Paper/tables/table2.tex",  ///
eqlabels(" " " ") b(3) booktabs mtitle label  ///
mtitles("\shortstack{Respondent's\\Highest\\Education\\Completed}"  ///
"\shortstack{Respondent's\\Highest\\Education\\Completed}"  ///
"\shortstack{2nd Respondent's\\Highest\\Education\\Completed}"  ///
"\shortstack{Father's\\Highest\\Education\\Completed}"  ///
"\shortstack{Mother's\\Highest\\Education\\Completed}"  ///
"\shortstack{Number\\Books\\Childhood}")  ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) keep(p_ottoman) replace  ///
se stats(N FE Model Demographic Geographic Income r2, fmt(%15.0fc 0 %9.2f) ///
labels("Observations" "Country FE" Model "Demographic Ctrls" "Geographic Ctrls" "Perception Income" R-squared)) ///	
nonotes addnotes("Note: The dependent variables are: highest education completed from 1 - No degree/ No education to"  ///
"8 - Master's degree or PhD and number of books in childhood from 1 - No or very few to" ///
"5 - Enough to fill 3 or 4 bookcases. Demographic controls include: age, gender, urban/rural location."  ///
"Geographic controls include: average temperature, ln(average altitude), ln(average slope)," /// 
"ln(average precipitation), wheat growth suitability, distance from rivers, distance from the sea, latitude, and longitude"  ///
"The social scale control is the self-reported 1-10 social scale positioning." ///
"Models are weighted linear regressions, with standard errors clustered at the PSU level."  ///
"*** = p<.001; ** = p<.01, *=p<.05, +=p<.10.")


*********
*TABLE 4*
*********
eststo clear
/* corruption Road\\Police */
quietly reg q801a p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model1, title("Payments\\Road\\Police")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* corruption Offical Doc. */
quietly reg q801b p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model2, title("Payments\\to get\\Offical Doc.")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* corruption Public Edu.\\Primary or\\Sec.y*/
replace q801d = . if q801d<=0 | q801d >11
quietly reg q801d p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model3, title("Payments\\to receive\\Public Edu.\\Primary or\\Sec.")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* corruption Public Edu.\\Vocational*/
quietly reg q801e p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model4, title("Payments\\to receive\\Public Edu.\\Vocational")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* corruption Public Health\\Treatment*/
quietly reg q801f p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model5, title("Payments\\to receive\\Public Health\\Treatment")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"

/* corruption Unemployment\\Benefits*/
replace q801g = . if q801g<=0 | q801g >11
quietly reg q801g p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model6, title("Payments\\to receive\\Unemployment\\Benefits")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"

/* corruption Social Sec.\\Benefits*/
quietly reg q801h p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model7, title("Payments\\to receive\\Social Sec.\\Benefits")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* corruption Gov. officials\\are\\Corrupt*/
quietly reg q814c p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model8, title("How many\\Gov. officials\\are\\Corrupt?")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* corruption Loc Gov. Rep.\\are\\Corrupt*/
quietly reg q814d p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr q109_1 urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model9, title("How many\\Loc Gov. Rep.\\are\\Corrupt?")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"



esttab using "$dopath/Paper/tables/table4.tex",  ///
b(3) booktabs mtitle label  ///
mtitles("\shortstack{Payments\\Road\\Police}"  ///
"\shortstack{Payments\\to get\\Offical Doc.}"  ///
"\shortstack{Payments\\to receive\\Public Edu.\\Primary or Sec.}"  ///
"\shortstack{Payments\\to receive\\Public Edu.\\Vocational}"  ///
"\shortstack{Payments\\to receive\\Public Health\\Treatment}"  ///
"\shortstack{Payments\\to receive\\Unemployment\\Benefits}"  ///
"\shortstack{Payments\\to receive\\Social Sec.\\Benefits}"  ///
"\shortstack{How many\\Gov. officials\\are\\Corrupt?}"  ///
"\shortstack{How many\\Loc Gov. Rep.\\are\\Corrupt?}")  ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) keep(p_ottoman) replace  ///
se stats(N FE Model Demographic Geographic r2 aic ll, fmt(%15.0fc 0 %9.2f) ///
labels("Observations" "Country FE" Model "Demographic Ctrls" "Geographic Ctrls" R-squared)) ///	
nonotes addnotes("Note: Demographic controls include: age, gender, urban/rural location. Geographic controls include: average temperature, ln(average altitude), ln(average slope)," /// 
"ln(average precipitation), wheat growth suitability, distance from rivers, distance from the sea, latitude, and longitude. Models are weighted linear regressions, with" ///
"standard errors clustered at the PSU level. *** = p<.001; ** = p<.01, *=p<.05, +=p<.10.")
 	

********
*TABLE5*
********

eststo clear
/* trust in people meet for first time*/
quietly reg q405c p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model1, title("Trust People\\You Meet\\First Time")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* wallet returned - negative and significant. */
quietly reg q423 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model2, title("Likelihood\\of Returning\\Wallet")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* risk acceptance */
quietly reg q428 p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model3, title("Willingness\\to Take\\Risks")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* what it takes to succeed , no difference, nonsignificant*/
*gen workeffort = .
*replace workeffort = 1 if q409==1 | q409==2
*replace workeffort = 0 if q409==3 | q409==4
quietly logit workeffort p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model4, title("Need Effort\\and Intelligence\\to Succeed")
estadd local FE "Yes"
estadd local Model "Logit"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* democracy , more support, significant. */
*gen democracy = . 
*replace democracy = 1 if q412 == 1
*replace democracy = 0 if q412 == 2 | q412 == 3
quietly logit democracy p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model5, title("Democracy\\is\\Preferable")
estadd local FE "Yes"
estadd local Model "Logit"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* competition */
replace q417c = . if q417c<=0 | q417c >11
quietly reg q417c p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model6, title("Competition\\is\\Harmful")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* market economy */
quietly reg q417b p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model7, title("Private\\Ownership is\\Good")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* market economy , more support, singif at .11*/
*gen marketeconomy = .
*replace marketeconomy = 1 if q411==1
*replace marketeconomy = 0 if q411==2 | q411==3

quietly logit marketeconomy p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model8, title("Market\\Economy is\\Good")
estadd local FE "Yes"
estadd local Model "Logit"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


/* q404 - inst trust variables */
*"Trust\\Government"
quietly reg q404b p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model9, title("Trust\\Government")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"

*"Trust\\Army"
quietly reg q404h p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model10, title("Trust\\Army")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"

*Trust\\Banks
quietly reg q404j p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban  i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model11, title("Trust\\Banks")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"

*Trust\\Foreign\\Investors
quietly reg q404k p_ottoman tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance age_pr gender_pr urban i.ctry if otthist == 1 [pw=weight_one], cluster(PSU_name)
eststo model12, title("Trust\\Foreign\\Investors")
estadd local FE "Yes"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Geographic "Yes"


esttab using "$dopath/Paper/tables/table5.tex",  ///
eqlabels(" " " ") b(3) booktabs mtitle label  ///
mtitles("\shortstack{Trust Peple\\You Meet\\First Time}"  ///
"\shortstack{Likelihood\\of Returning\\Wallet}"  ///
"\shortstack{Willingness\\to Take\\Risks}"  ///
"\shortstack{Need Effort\\and Intelligence\\to Succeed}"  ///
"\shortstack{Democracy\\is\\Preferable}"  ///
"\shortstack{Competition\\is\\Harmful}"  ///
"\shortstack{Private\\Ownership is\\Good}"  ///
"\shortstack{Market\\Economy is\\Good}"  ///
"\shortstack{Trust\\Government}"  ///
"\shortstack{Trust\\Army}"  ///
"\shortstack{Trust\\Banks}"  ///
"\shortstack{Trust\\Foreign\\Investors}")  ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) keep(p_ottoman) replace  ///
se stats(N FE Model Demographic Geographic r2 aic ll, fmt(%15.0fc 0 %9.2f) ///
labels("Observations" "Country FE" Model "Demographic Ctrls" "Geographic Ctrls" R-squared)) ///	
nonotes addnotes("Note: Demographic controls include: age, gender, urban/rural location. Geographic controls include: average temperature, ln(average altitude), ln(average slope)," /// 
"ln(average precipitation), wheat growth suitability, distance from rivers, distance from the sea, latitude, and longitude"  ///
"Models are weighted linear regressions, with standard errors clustered at the PSU level. *** = p<.001; ** = p<.01, *=p<.05, +=p<.10.")
 
 

	
***********
*Table A11*
***********
eststo clear
/* corruption police */
encode nuts_id, gen(nuts_id_num)
quietly reg q109_1 p_ottoman age_pr gender_pr urban i.nuts_id_num if otthist == 1 & nuts_id_num !=265 [pw=weight_one], cluster(PSU_name)
eststo model2, title("Respondent's Highest Education Completed")
estadd local CFE "Yes"
estadd local CTRFE "No"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Income "No"


/* post treatment income control */
quietly reg q109_1 p_ottoman age_pr gender_pr urban PRq315 i.nuts_id_num if otthist == 1 & nuts_id_num !=265 [pw=weight_one], cluster(PSU_name)
eststo model3, title("Respondent's Highest Education Completed")
estadd local CFE "Yes"
estadd local CTRFE "No"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Income "Yes"

/* secondary respondent*/
quietly reg q109_2 p_ottoman age_pr gender_pr urban i.nuts_id_num if otthist == 1 & nuts_id_num !=265 [pw=weight_one], cluster(PSU_name)
eststo model4, title("Respondent's Highest Education Completed")
estadd local CFE "Yes"
estadd local CTRFE "No"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Income "No"


/* father educ*/
quietly reg q110_1 p_ottoman age_pr gender_pr urban i.nuts_id_num if otthist == 1 & nuts_id_num !=265 [pw=weight_one], cluster(PSU_name)
eststo model5, title("Father's Highest Education Completed")
estadd local CFE "Yes"
estadd local CTRFE "No"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Income "No"

/* mother educ*/
quietly reg q111_1 p_ottoman age_pr gender_pr urban i.nuts_id_num if otthist == 1 & nuts_id_num !=265 [pw=weight_one], cluster(PSU_name)
eststo model6, title("Mother's Highest Education Completed")
estadd local CFE "Yes"
estadd local CTRFE "No"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Income "No"


/* books growing up */
replace q203 = . if q203<=0 | q203 >6
quietly reg q203 p_ottoman age_pr gender_pr urban  i.nuts_id_num if otthist == 1 & nuts_id_num !=265 [pw=weight_one], cluster(PSU_name)
eststo model7, title("No. Books Childhood")
estadd local CFE "Yes"
estadd local CTRFE "No"
estadd local Model "OLS"
estadd local Demographic "Yes"
estadd local Income "No"


esttab using "$dopath/Paper/tables/tableA11.tex",  ///
eqlabels(" " " ") b(3) booktabs mtitle label  ///
mtitles("\shortstack{Respondent's\\Highest\\Education\\Completed}"  ///
"\shortstack{Respondent's\\Highest\\Education\\Completed}"  ///
"\shortstack{2nd Respondent's\\Highest\\Education\\Completed}"  ///
"\shortstack{Father's\\Highest\\Education\\Completed}"  ///
"\shortstack{Mother's\\Highest\\Education\\Completed}"  ///
"\shortstack{Number\\Books\\Childhood}")  ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) keep(p_ottoman) replace  ///
se stats(N CFE CTRFE Model Demographic Income r2, fmt(%15.0fc 0 %9.2f) ///
labels("Observations" "County FE" "Country FE" Model "Demographic Ctrls" "Perception Income" R-squared)) ///	
nonotes addnotes("Note: The dependent variables are: highest education completed from 1 - No degree/ No education to"  ///
"8 - Master's degree or PhD and number of books in childhood from 1 - No or very few to" ///
"5 - Enough to fill 3 or 4 bookcases. Demographic controls include: age, gender, urban/rural location."  ///
"The social scale control is the self-reported 1-10 social scale positioning." ///
"Models are weighted linear regressions, with standard errors clustered at the PSU level."  ///
"*** = p<.001; ** = p<.01, *=p<.05, +=p<.10.")	
